package com.education.welco.controller.app;


import com.education.common.core.BaseController;
import com.education.common.utils.ApiReturnObject;
import com.education.welco.pojo.LQuestions;
import com.education.welco.pojo.SQuestions;
import com.education.welco.pojo.SQuestionsStu;
import com.education.welco.service.ILQuestionsService;
import com.education.welco.service.ISQuestionsService;
import com.education.welco.service.ISQuestionsStuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 试卷试题 信息操作处理
 *
 * @author d
 * @date 2020-05-08
 */

@Api(tags = {"APP-学校课程--试题"})
@RestController
@RequestMapping("/app/sQuestions")
public class AppSQuestionsController extends BaseController {

    @Autowired
    private ILQuestionsService questionsService;


    @Autowired
    private ISQuestionsService isQuestionsStuService;



//    @ApiOperation(value = "学校课程--试题接口", httpMethod = "GET")
//    @GetMapping("/findByQuestions")
//    public ApiReturnObject findByQuestions(Integer catalogId,Integer type) {
//        //type  1单选  2多选 3判断 4简答
//        if (null == catalogId || null == type) {
//            return new ApiReturnObject("200", "catalogId或type字段为空", "catalogId或type字段为空");
//        }else {
//            List<LQuestions> questionsList = questionsService.selectByCatalogIdAndType(catalogId, type);
//            return new ApiReturnObject("200", "查询成功", questionsList.size(),questionsList);
//        }
//    }


    @ApiOperation(value = "学校课程--试题接口", httpMethod = "GET")
    @GetMapping("/findByQuestions")
    public ApiReturnObject findByQuestions(Integer catalogId,Integer type, Integer classId) {
        //type  1单选  2多选 3判断 4简答
        if (null == catalogId || null == type) {
            return new ApiReturnObject("200", "catalogId或type字段为空", "catalogId或type字段为空");
        }else {
            List<SQuestions> sQuestionsList = isQuestionsStuService.selectByCatalogIdAndType(catalogId, type, classId);
            return new ApiReturnObject("200", "查询成功", sQuestionsList.size(),sQuestionsList);
        }
    }

}